package com.zyf.controller;

import com.zyf.pojo.Prescription;
import com.zyf.service.PrescriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
public class PrescriptionController {

    @Autowired
    private PrescriptionService prescriptionService;

    @PostMapping("/savePrescription")
    public Map<String,Object> savePrescription(@RequestBody List<Prescription> prescription){
        Map<String,Object> map = new HashMap<>();

        try {
            prescriptionService.saveBatch(prescription);
            map.put("msg","处方保存成功");
            map.put("code","200");
        } catch (Exception e) {
            e.printStackTrace();
            map.put("msg","处方保存失败.....");
            map.put("code",500);
        }

        return map;
    }




}
